<template>
  <div>
    <div class="check">
      <div>
        <span v-model="text" class="spanstyle">{{text}}</span>
        <img
          @click="showbox"
          class="imgstyle"
          :style="{ width: size + 'px', height: size + 'px' }"
          :src="fold ? arrowup : arrowdown"
        />
      </div>
      <div v-show="fold" class="dropbox">
        <span
          @click="check(item)"
          v-for="(item, index) in select"
          :key="index"
          class="select"
          >{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props:['select'],
  data() {
    return {
      text:"选择框",
      fold: false,
      border: true,
      size: 18,
      arrowdown: require("../../asset/arrow/下箭头.png"),
      arrowup: require("../../asset/arrow/上箭头.png"),
    };
  },
  methods: {
    showbox() {
      this.fold = !this.fold;
    },
    check(item) {
        this.text=item.name
        this.fold = !this.fold;
        this.$emit('selectbox',item.name)
    },
  },
};
</script>
<style scoped>
.check {
  width: 70px;
  height: 20px;
  font-size: 12px;
  padding: 2px 5px 6px 8px;
  text-align: center;
  border: 1px solid #d9d9d9;
  border-radius: 5px;
}
.imgstyle {
  position: relative;
  top: 5px;
}
.dropbox {
  position: relative;
  top: 6px;
  height: 80px;
  border: 1px solid #F7F7F7;
  box-shadow:0 4px 3px rgb(0 0 0 / 3%);
  border-radius: 0 0 5px 5px;
  overflow-y: scroll;
}
.select {
  display: block;
  width: 100%;
  height: 25px;
  line-height: 25px;
}
.spanstyle{
    color: #ccc;
    display: inline-block;
    width: 40px;
}
</style>